
function IfShow(ShowMsg) {
	if (ShowMsg == "") {
		return false;
	} else {
		return true;
	}
}
function isNumeric(obj, ShowMsg) {
	var show = IfShow(ShowMsg);
	var IfTrue = obj.value.search(/^(-|\+)?\d+(\.\d+)?$/) != -1;
	if (show && IfTrue == false) {
		alert(ShowMsg);
		obj.focus();
		obj.select();
		return false;
	} else {
		return true;
	}
}
function isNull(obj, ShowMsg) {
	var show = IfShow(ShowMsg);
	if (obj.value == "") {
		if (show) {
			alert(ShowMsg);
		}
		obj.focus();
		obj.select();
		return false;
	} else {
		return true;
	}
}
function MailCheck(obj, ShowMsg) {
	var show = IfShow(ShowMsg);
	if (obj.value != "") {
		var ok1 = obj.value.indexOf("@");
		var ok2 = obj.value.indexOf(".");
		if (!((ok1 != -1) && (ok2 != -1))) {
			if (show) {
				alert(ShowMsg);
			}
			obj.focus();
			obj.select();
			return false;
		}
		var allowstrlist = "&#%<>";
		var endvalue = true;
		for (i = 0; i < obj.value.length; i++) {
			if (allowstrlist.indexOf(obj.value.substr(i, 1)) != -1) {
				endvalue = false;
				break;
			}
		}
		if (endvalue == false) {
			if (show) {
				alert(ShowMsg);
			}
			obj.focus();
			obj.select();
			return false;
		}
		return true;
	} else {
		if (show) {
			alert(ShowMsg);
		}
		obj.focus();
		obj.select();
		return false;
	}
}
function Trim(str) {
	if (str == "") {
		return str;
	}
	var newStr = "" + str;
	RegularExp = /^\s+|\s+$/gi;
	return newStr.replace(RegularExp, "");
}
function LTrim(str) {
	if (str == "") {
		return str;
	}
	var newStr = "" + str;
	RegularExp = /(^\s*)/g;
	return newStr.replace(RegularExp, "");
}
function RTrim(str) {
	if (str == "") {
		return str;
	}
	var newStr = "" + str;
	RegularExp = /(\s*$)/g;
	return newStr.replace(RegularExp, "");
}
function isMashText(obj, ShowMsg) {
	var show = IfShow(ShowMsg);
	var filter = /^\s*[.A-Za-z0-9_-]{5,15}\s*$/;
	if (obj.value == "") {
		if (show) {
			alert(ShowMsg);
		}
		obj.focus();
		obj.select();
		return false;
	} else {
		if (!filter.test(obj.value)) {
			alert(ShowMsg);
					obj.focus();
		obj.select();
		return false;
		}
		else{
			return true;
		}

	}
}
function openNewWindow(winUrl,winName,sizeCode)
{

	switch (sizeCode)
	{
		case 'l':
		case 'L':
			lenWidth = screen.width; 
			lenHeight = screen.Height; 
			locLeft = 0;
			locTop = 0;
			break;
		case 'm':
		case 'M':
			lenWidth = screen.width * 2/3 
			lenHeight = screen.height * 2/3 
			locLeft = (screen.width)/10
			locTop = (screen.Height)/10
			break;
		case 's':
		case 'S':
			lenWidth = screen.width * 1/3 
			lenHeight = screen.height * 1/3 
			locLeft = (screen.width)/10
			locTop = (screen.Height)/10
			break;
		default:
			lenWidth = screen.width * 2/3 
			lenHeight = screen.height * 2/3 
			locLeft = (screen.width)/10
			locTop = (screen.Height)/10
	}	
	openNewWindowSize(winUrl,winName,lenWidth,lenHeight,locLeft,locTop);

}
function openNewWindowSize(winUrl,winName,lenWidth,lenHeight,locLeft,locTop)
{

	ctlStr = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=" + lenWidth + ",height=" + lenHeight + ",left=" + locLeft+ ",top=" + locTop;
	controlWindow = window.open(winUrl,winName,ctlStr);
	controlWindow.focus();

}
